#pragma GCC optimize(2)
#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
#include <stack>
#include <bitset>
#define F first
#define S second
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int N=2e5+10;
int a[N];
void solve()
{
	int n;
	cin>>n;
	vector<int> v;
	for(int i=1;i<=n;i++)
	{
		
		cin>>a[i];
		if(i!=1 && a[i-1]!=1)
		{
			v.push_back(1);
		}
		v.push_back(a[i]);
	}
	cout<<v.size()<<endl;
	for(auto it:v) cout<<it<<' ';
	cout<<endl;
}
int main()
{
	IOS;
	int T=1;
	cin>>T;

	while(T--)
	{
		solve();
	}

	return 0;
}

